<?php
class ORMSample extends ORMBase {
  public function __construct() {
    parent::__construct('Sample');
  }

  public function __toEpObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMSampleAttribute.class.php';
    $epObject->trackId = isset($object->trackId) ? $object->trackId : '';
    $epObject->name = isset($object->name) ? $object->name : '';
    $epObject->price = isset($object->price) ? $object->price : 0;
    $epObject->unit = isset($object->unit) ? $object->unit : '';
    $epObject->type = isset($object->type) ? $object->type : '';
    $epObject->model = isset($object->model) ? $object->model : '';
    if (isset($epObject->attributes)) {
      $epObject->attributes->removeAll();
      foreach ($object->attributes as &$item) {
        $epObject->attributes[] = $this->__getEpObject_4_lvl_1_object($myManager, $item, new ORMSampleAttribute(), 'SampleAttribute');
      }
    }
    return $epObject;
  }

  public function __toObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMSampleAttribute.class.php';
    $object->id = $epObject->oid;
    $object->trackId = $epObject->trackId;
    $object->name = $epObject->name;
    $object->price = $epObject->price;
    $object->unit = $epObject->unit;
    $object->type = $epObject->type;
    $object->model = $epObject->model;
    $object->attributes = array();
    if (isset($epObject->attributes)) {
      foreach ($epObject->attributes as &$item) {
        $object->attributes[] = $this->__getObject_4_lvl_1_ep_object($myManager, $item, new ORMSampleAttribute());
      }
    }
    return $object;
  }
}
?>
